package com.websocket.handshake;

public class HandshakeRegistry {

    private String endpoint;
    private int port = 8080;
    private final HandshakeExecutionChain interceptorChain = new HandshakeExecutionChain();

    public HandshakeRegistry setEndpoint(String path) {
        endpoint = path;
        return this;
    }

    public HandshakeRegistry setPort(int port) {
        this.port = port;
        return this;
    }

    public HandshakeRegistry addInterceptor(HandshakeInterceptor interceptor) {
        interceptorChain.addInterceptor(interceptor);
        return this;
    }

    public HandshakeRegistry addInterceptors(HandshakeInterceptor interceptor, HandshakeInterceptor... interceptors) {
        interceptorChain.addInterceptor(interceptor);
        if (interceptors != null) {
            for (HandshakeInterceptor handshakeInterceptor : interceptors) {
                interceptorChain.addInterceptor(handshakeInterceptor);
            }
        }
        return this;
    }

    public String getEndpoint() {
        return endpoint;
    }

    public int getPort() {
        return port;
    }

    public HandshakeExecutionChain getInterceptorChain() {
        return interceptorChain;
    }
}
